﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<IndyMosaic.Models.Web.BinaryResource>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <h2>Index</h2>
    <table style="color: White;">
        <thead>
            <tr style="font-weight: bold;">
                <td>Name</td>
                <td>Type</td>
                <td></td>
                <td>Delete</td>
            </tr>
        </thead>
        <tbody>
            <% using (Html.BeginForm())
               {      
                   foreach (var resource in Model)
                   {
                       string url = string.Format("{0}?id={1}", Url.Content("~/getImage.axd"), resource.ID.ToString());
                    %>
                    <tr>
                        <td><%: resource.FileName%> </td>
                        <td><%: resource.ContentType%> </td>
                        <td>
                            <% if (resource.ContentType.Contains("image"))
                               {  %>
                                <img src="<%: url %>" />
                             <%}
                               else
                               {%>
                                <a href="<%: url %>" target="_blank" />
                               <%} %>
                        </td>
                        <td> <%: Html.ActionLink("Delete", "Delete", new { id = resource.ID }, new { @class = "delete" })%> </td>
                    </tr>    
                    <%}
               }%>        
        </tbody>
    </table>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    
</asp:Content>

